<?php
use Yii\helpers\Html;
use yii\bootstrap\ActiveForm;
use yii\helpers\Url;
$this->title = '登陆设置';
?>
<div class="container">
    <div class="row">
      
        <?php echo $this->render('_leftnav') ?>

        <div class="col-md-10">
          <div class="page-header clearfix">
            <h1 class="pull-left">登录</h1>
            <div class="pull-right">

                                            
            </div>
          </div>

          <?php echo $this->render('_usersetting') ?>
	        <!--站点配置表单类-->
	        <?php
	        $form = ActiveForm::begin([
		        'options' => ['class' => 'form-horizontal','id'=>'site-form'],
		        'action'=>Url::to(['system/userloginsave']),
		        'method'=>'post',
		        'fieldConfig' => [
			        'template' => '<fieldset><div class="form-group"><div class="col-md-3 control-label">{label}</div><div class="controls col-md-8 radios">{input}{error}<p class="help-block"></p></div></div></fieldset><br>'
		        ],
	        ]);
	        ?>

	        <?= $form->field($model, 'login_limit',['template'=>'<fieldset><div class="form-group"><div class="col-md-3 control-label">{label}</div><div class="controls col-md-8 radios">{input}{error}<p class="help-block">开启后同一帐号只能在一处登录</p></div></div></fieldset><br>'])->radioList(['1'=>'开启','0'=>'关闭']) ?>

	        <?= $form->field($model, 'other_login')->radioList(['1'=>'开启','0'=>'关闭']) ?>

<fieldset>
<div class="form-group">
	<?= $form->field($model, 'login_protect',['template'=>'<div class="col-md-3 control-label">{label}</div><div class="controls col-md-8 radios">{input}{error}<p class="help-block">开启后，登录时用户连续多次输入错误密码时暂时封禁用户,此功能不影响admin手动永久封禁用户</p></div>'])->radioList(['1'=>'开启','0'=>'关闭']) ?>

      <div style="display: none;" id="times_and_minutes" class="col-md-8 col-md-offset-3">
        <div class="row">
          <div class="col-md-4 lock-user-text-right">
            用户连续输入错误密码
          </div>
          <div class="controls col-md-2 form-group">

	          <?= $form->field($model, 'protect_one_num',['template'=>'{input}{error}'])->textInput(['class'=>'form-control','id'=>'temporary_lock_allowed_times']) ?>

<!--            <input data-explain="" data-widget-cid="widget-1" id="temporary_lock_allowed_times" name="temporary_lock_allowed_times" class="form-control" value="5" type="text">-->
          <div class="help-block" style="display:none;"></div>
          </div>
          <div class="col-md-3 lock-user-text-left">
            次，将暂时封禁用户
          </div>
        </div>
        <div class="row">
          <div class="col-md-4 lock-user-text-right">
            同一IP连续输入错误密码
          </div>
          <div class="controls col-md-2 form-group">

	          <?= $form->field($model, 'protect_two_num',['template'=>'{input}{error}'])->textInput(['class'=>'form-control','id'=>'temporary_lock_allowed_times']) ?>

<!--            <input id="temporary_lock_allowed_times" name="ip_temporary_lock_allowed_times" class="form-control" value="20" type="text">-->
          </div>
          <div class="col-md-3 lock-user-text-left">
            次，将暂时封禁IP
          </div>
        </div>


        <div class="row">
          <div class="col-md-4 lock-user-text-right">
            经过
          </div>
          <div class="controls col-md-2 form-group">

	          <?= $form->field($model, 'protect_two_time',['template'=>'{input}{error}'])->textInput(['class'=>'form-control','id'=>'emporary_lock_minutes']) ?>

<!--            <input data-explain="" data-widget-cid="widget-2" id="temporary_lock_minutes" name="temporary_lock_minutes" class="form-control" value="20" type="text">-->
          <div class="help-block" style="display:none;"></div></div>
          <div class="col-md-3 lock-user-text-left">
            分钟后，解锁用户/IP
          </div>  
        </div>
      </div> 
  </div>
  </fieldset>

      <fieldset data-role="oauth2-setting" data-type="weibo">
      <legend>微博登录接口</legend>

	      <?= $form->field($model, 'sina_status',['template'=>'<div class="form-group"><div class="col-md-3 control-label">{label}</div><div class="controls col-md-8 radios">{input}{error}<div class="help-block"><a href="http://open.weibo.com/authentication/" target="_blank">申请微博登录接口</a></div></div></div>'])->radioList(['1'=>'开启','0'=>'关闭']) ?>

	      <?= $form->field($model, 'sina_app_key')->textInput(['class'=>'form-control','id'=>'weibo_key']) ?>

	      <?= $form->field($model, 'sina_app_secret')->textInput(['class'=>'form-control','id'=>'weibo_secret']) ?>

	      <?= $form->field($model, 'sina_login_validation',['template'=>'<div class="form-group"><div class="col-md-3 control-label">{label}</div><div class="controls col-md-8 radios">{input}{error}<p class="help-block">在微博登录接口官方审核通过您的接入申请以前，请不要开启此选项，否则可能审核将无法通过</p></div></div>'])->radioList(['1'=>'开启','0'=>'关闭']) ?>

	      <div class="form-group">
          <div class="col-md-3 control-label">
            <label for=""></label>
          </div>
          <div class="controls col-md-8 radios">
            <div class="help-block"><a href="#port">最后一步,请在底部输入登录接口验证代码&gt;</a></div>
          </div>
        </div>


          </fieldset>
      <fieldset data-role="oauth2-setting" data-type="qq">
      <legend>QQ登录接口</legend>


	      <?= $form->field($model, 'qq_status',['template'=>'<div class="form-group"><div class="col-md-3 control-label">{label}</div><div class="controls col-md-8 radios">{input}{error}<div class="help-block"><a href="http://connect.qq.com/" target="_blank">申请QQ登录接口</a></div></div></div>'])->radioList(['1'=>'开启','0'=>'关闭']) ?>

	      <?= $form->field($model, 'qq_app_id')->textInput(['class'=>'form-control','id'=>'qq_key']) ?>

	      <?= $form->field($model, 'qq_app_key')->textInput(['class'=>'form-control','id'=>'qq_secret']) ?>

	      <?= $form->field($model, 'qq_login_validation',['template'=>'<div class="form-group"><div class="col-md-3 control-label">{label}</div><div class="controls col-md-8 radios">{input}{error}<p class="help-block">在QQ登录接口官方审核通过您的接入申请以前，请不要开启此选项，否则可能审核将无法通过</p></div></div>'])->radioList(['1'=>'开启','0'=>'关闭']) ?>

                    <div class="form-group">
          <div class="col-md-3 control-label">
            <label for=""></label>
          </div>
          <div class="controls col-md-8 radios">
            <div class="help-block"><a href="#port">最后一步,请在底部输入登录接口验证代码&gt;</a></div>
          </div>
        </div>
          </fieldset>

      <fieldset data-role="oauth2-setting" data-type="weixinweb">
      <legend>微信网页登录接口</legend>

	      <?= $form->field($model, 'wechat_status',['template'=>'<div class="form-group"><div class="col-md-3 control-label">{label}</div><div class="controls col-md-8 radios">{input}{error}<div class="help-block"><a href="https://open.weixin.qq.com/cgi-bin/frame?t=home/web_tmpl&amp;lang=zh_CN" target="_blank">申请微信网页登录接口</a></div></div></div>'])->radioList(['1'=>'开启','0'=>'关闭']) ?>

	      <?= $form->field($model, 'wechat_app_id')->textInput() ?>

	      <?= $form->field($model, 'wechat_app_secret')->textInput(['class'=>'form-control','id'=>'weixinweb_secret']) ?>


	      <?= $form->field($model, 'wechat_login_validation',['template'=>'<div class="form-group"><div class="col-md-3 control-label">{label}</div><div class="controls col-md-8 radios">{input}{error}<p class="help-block">在微信网页登录接口官方审核通过您的接入申请以前，请不要开启此选项，否则可能审核将无法通过</p></div></div>'])->radioList(['1'=>'开启','0'=>'关闭']) ?>

                </fieldset>
      <fieldset data-role="oauth2-setting" data-type="weixinmob">
      <legend>微信内分享登录接口</legend>

	      <?= $form->field($model, 'wechat_share_status',['template'=>'<div class="form-group"><div class="col-md-3 control-label">{label}</div><div class="controls col-md-8 radios">{input}{error}<div class="help-block"><a href="https://mp.weixin.qq.com/cgi-bin/readtemplate?t=register/step1_tmpl&amp;lang=zh_CN" target="_blank">申请微信内分享登录接口</a></div></div></div>'])->radioList(['1'=>'开启','0'=>'关闭']) ?>

	      <?= $form->field($model, 'wechat_share_id')->textInput(['id'=>'weixinmob_key','class'=>'form-control']) ?>

	      <?= $form->field($model, 'wechat_share_secret')->textInput(['class'=>'form-control','id'=>'weixinmob_secret']) ?>

                </fieldset>
  
  <fieldset>
    <legend id="port">登录接口验证代码</legend>

	  <?= $form->field($model, 'validation_code',['template'=>'<div class="form-group"><div class="col-md-3 control-label">{label}</div><div class="controls col-md-8">{input}{error}<div class="help-block">在申请第三方登录接口时，会要求验证您的网站域名。请把相关验证代码粘到此处，然后提交保存。</div></div></div>'])->textarea(['rows'=>5]) ?>

  </fieldset>

  <div class="form-group">
    <div class="controls col-md-offset-3 col-md-8">
	    <?= Html::submitButton('提交', ['class'=>'btn btn-primary']) ?>
    </div>
  </div>
	        <?php ActiveForm::end();?>
		</div>
    </div>
</div>
<script>
	$(document).on('click','#userloginform-login_protect div label input',function(){
		var val = $(this).val();
		if(val == "1")
		{
			$("#times_and_minutes").css("display","block");
		}
		else
		{
			$("#times_and_minutes").css("display","none");
		}
	})
</script>